package com.example.jussi.staticbroadcastdemo;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Created by admin on 2018/12/2.
 */

public class BroadCast2 extends BroadcastReceiver {
    /**
     * setTicker()设置的是通知时在状态栏显示的通知内容，一般是一段文字，例如在状态栏显示“您有一条短信，待查收”。
     * setTitle()设置的是收到通知后你将状态栏下拉后，显示的通知的具体内容的标题。
     * @param context
     * @param intent
     */
    @Override
    public void onReceive(Context context, Intent intent) {
        NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
        Notification.Builder builder = new Notification.Builder(context);
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setTicker("广播消息");
        builder.setContentTitle("您有一条广播消息");
        builder.setContentText("It is jussi's BroadCast Demo.");
        manager.notify(0x01, builder.build());
    }
}
